package com.health.central_authentication.handler;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.health.result.CodeStatus;
import com.health.result.ResultUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 用户未登录处理器
 * @author: zipeng Li
 * 2021/6/13  13:38
 */
@Component
public class DGUTAuthenticationEntryPoint implements AuthenticationEntryPoint {
    private static final String appid = "javaee";

    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
        // 重定向到中央认证页
        httpServletResponse.sendRedirect("https://cas.dgut.edu.cn?appid=" + appid);
    }
}
